// Basic types and values used in the runtime library.

#undef bool
#undef false
#undef true

typedef signed int   int8    __attribute__ ((mode (QI)));
typedef unsigned int uint8   __attribute__ ((mode (QI)));
typedef signed int   int16   __attribute__ ((mode (HI)));
typedef unsigned int uint16  __attribute__ ((mode (HI)));
typedef signed int   int32   __attribute__ ((mode (SI)));
typedef unsigned int uint32  __attribute__ ((mode (SI)));
typedef signed int   int64   __attribute__ ((mode (DI)));
typedef unsigned int uint64  __attribute__ ((mode (DI)));
typedef float        float32 __attribute__ ((mode (SF)));
typedef double       float64 __attribute__ ((mode (DF)));
typedef unsigned int uintptr __attribute__ ((mode (pointer)));

typedef _Bool bool;
typedef uint8 byte;

typedef int goint;

enum {
	false = 0,
	true = 1,
};

typedef	struct __go_open_array      Slice;
typedef	struct __go_string          String;
typedef struct __go_interface       Iface;
typedef	struct __go_empty_interface Eface;
typedef	struct __go_type_descriptor Type;
typedef	struct __go_defer_stack     Defer;
typedef	struct __go_panic_stack     Panic;

typedef struct __go_func_type       FuncType;
typedef struct __go_map_type        MapType;


// A slice is an instance of this structure.
struct __go_open_array {
	// The elements of the array.
	// In use in the compiler this is a pointer to the element type.
	void *__values;

	// The number of elements in the array.  Note that this is "int",
	// not "size_t".  The language definition says that "int" is large
	// enough to hold the size of any allocated object.  Using "int"
	// saves 8 bytes per slice header on a 64-bit system with 32-bit
	// ints.
	int __count;

	// The capacity of the array--the number of elements that can fit in
	// the __VALUES field.
	int __capacity;
};

// A string is an instance of this structure.
struct __go_string
{
	/* The bytes.  */
	const unsigned char *__data;
	/* The length.  */
	int __length;
};

// A variable of interface type is an instance of this struct,
// if the interface has any methods.
struct __go_interface
{
	// A pointer to the interface method table.  The first pointer is
	// the type descriptor of the object.  Subsequent pointers are
	// pointers to functions.  This is effectively the vtable for this
	// interface.  The function pointers are in the same order as the
	// list in the internal representation of the interface, which sorts
	// them by name.
	const void **__methods;

	// The object.  If the object is a pointer--if the type descriptor
	// code is GO_PTR or GO_UNSAFE_POINTER--then this field is the value
	// of the object itself.  Otherwise this is a pointer to memory
	// which holds the value.
	void *__object;
};

// A variable of an empty interface type is an instance of this struct.
struct __go_empty_interface
{
	// The type descriptor of the object.
	const struct __go_type_descriptor *__type_descriptor;

	// The object.  This is the same as __go_interface above.
	void *__object;
};

// The stack of panic calls.
struct __go_panic_stack {
	// The next entry in the stack.  */
	struct __go_panic_stack *__next;

	// The value associated with this panic.  */
	struct __go_empty_interface __arg;

	// Whether this panic has been recovered.  */
	bool __was_recovered;

	// Whether this panic was pushed on the stack because of an
	// exception thrown in some other language.
	bool __is_foreign;
};
